package xyz.erupt.flow.utils;

import xyz.erupt.core.exception.EruptApiErrorTip;

/**
 * 工作流工具
 */
public class WorkFlowUtils {
    /**
     * camunda Key转流程定义Id
     * @param key
     * @return
     */
    public static Long keyToWorkFlowDefinitionId(String key){
        if(key!=null&&!key.isEmpty()){
            String newId = key.replace("_", "");
            return Long.valueOf(newId);
        }else {
            throw new EruptApiErrorTip("不存在该key");
        }
    }

    /**
     * 流程定义id转camunda key
     * @param workFlowDefinitionId
     * @return
     */
    public static String workFlowDefinitionIdToKey(Long workFlowDefinitionId){
        if(workFlowDefinitionId!=null){
            return '_'+workFlowDefinitionId.toString();
        }else {
            throw new EruptApiErrorTip("流程定义id不能为null");
        }
    }
}
